package dimension.starry.block.machine.industry.smallLathe;

import dimension.starry.block.machine.industry.rollingMill.RollingMillTileEntity;
import dimension.starry.block.typeInterface.Machine;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class SmallLatheLeft extends Machine {

    @Override
    public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
        return new SmallLatheTileEntity(pos, state);
    }

    @Override
    public ActionResult onUse(
        BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit
    ) {
        if (!world.isClient()) {
            BlockEntity blockEntity = world.getBlockEntity(pos);
            if (blockEntity instanceof SmallLatheTileEntity && !((SmallLatheTileEntity) blockEntity).hasSteam()) {
                player.sendMessage(Text.translatable("starry_dimension.gui.message.machine_not_has_steam"));
            }
        }
        return super.onUse(state, world, pos, player, hand, hit);
    }

}
